package cece.controller;


import cece.entity.Music;
import cece.entity.MusicResp;
import cece.service.MusicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by Administrator on 2020/5/23.
 */
@Controller
public class MusicController {
    @Autowired
    MusicService musicService;

    @RequestMapping(value = "/findAll/{pageSie}/{pageNum}" ,method = RequestMethod.GET)
    @ResponseBody
    public MusicResp findAll(@PathVariable("pageSie")Integer pageSie, @PathVariable("pageNum")Integer pageNum){

        return musicService.findAll(pageSie,pageNum);
    }
    @RequestMapping(value = "/findByYid/{yid}",method = RequestMethod.GET)
    @ResponseBody
    public Music findByYid(@PathVariable("yid") Integer yid){
        return musicService.findByYid(yid);
    }
    @RequestMapping(value = "/findMusic/{zname}",method = RequestMethod.GET)
    @ResponseBody
    public List<Music> findMusic(String zname){
        musicService.findMusics(zname);
    /*    ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("MusicList");
        modelAndView.addObject(music)*/;
        return musicService.findMusics(zname);
    }
}
